const db = wx.cloud.database()
const _ = db.command
const $ = _.aggregate
Page({
  onLoad() {

    this.getFloorList()
  },
  // 获取每个教学楼的教室情况
  getFloorList() {
    db.collection('classVenue').aggregate()
      .group({
        _id: '$floor',
        num: $.addToSet('$name')
      })
      .sort({
        _id: 1
      })
      .end()
      .then(res => {
        console.log('教室数据', res)
        this.setData({
          list: res.list
        })
      })
  },
  //去单个教学楼预约
  goDetail(e) {
    let item = e.currentTarget.dataset.item
    wx.navigateTo({
      url: '/pages/class-reserve/class-reserve?floor=' + item._id,
    })
  }
})